package com.example.baselibrary.activity;

import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.Nullable;
import com.example.baselibrary.bean.PublicViewHolder;
import com.example.baselibrary.util.BaseResourceUtil;


import cc.vv.lkbasecomponent.base.ui.LKBaseActivity;

/**
 * 公共Activity基类<p>
 * @author  sun.li
 */
public abstract class BaseNewActivity extends BaseActivity {

    @CallSuper
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(initLayoutRes());
        initViewHolder(initViewHolderObject());
        super.onCreate(savedInstanceState);
    }

    /**
     * 初始化界面布局文件
     */
    protected abstract int initLayoutRes();

    /**
     * 初始化界面资源对象文件
     */
    protected abstract PublicViewHolder initViewHolderObject();

    /**
     * 初始化界面资源对象文件
     */
    protected abstract void baseOnClick(int viewId);

    @CallSuper
    @Override
    protected void initView(@Nullable Bundle bundle) {

    }

    /**
     * 初始化界面中所有控件
     */
    private void initViewHolder(PublicViewHolder viewHolder) {
        BaseResourceUtil.getInstance().initViewHolderResource(this,viewHolder, new BaseResourceUtil.ViewEventInterface() {
            @Override
            public void viewOnClick(int resId) {
                baseOnClick(resId);
            }
        });
    }

}
